DeflateBuffer: handle empty chunks in feed_data without raising#13015
Open
HrachShah wants to merge 2 commits into
Open
DeflateBuffer: handle empty chunks in feed_data without raising#13015HrachShah wants to merge 2 commits into
HrachShah wants to merge 2 commits into
Conversation
The chunked-transfer decoder resumes a paused res
for more information, see https://pre-commit.ci
❌ 3 Tests Failed:
View the top 3 failed test(s) by shortest run time
To view more test analytics, go to the Test Analytics Dashboard |
Merging this PR will not alter performance
Comparing Footnotes
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
What do these changes do?
Fix :class:
aiohttp.http_parser.DeflateBuffer(and thechunked-transfer decoder that drives it) raising
IndexErrorwhen a paused decoder is resumed with an emptychunk.
The chunked-transfer decoder calls :meth:
feed_datawithb""to resume a paused decompressor. The CM-byte sniff atthe top of :meth:
feed_datareadchunk[0]on the emptychunk and raised :class:
IndexError, which surfaced to theHTTP parser as an unhandled exception during response decoding.
Skip the CM-byte sniff when the chunk is empty. The downstream
decompressor already handles empty input correctly, so no
behaviour change for non-empty chunks.
Are there changes in behavior for the user?
Yes, but only in the failure mode: the parser no longer crashes
when an empty chunk is fed in to resume a paused decoder. For
all non-empty input the behaviour is unchanged.
Is it a substantial burden for the maintainers to support this?
No. Two-line change guarded by an
if not chunkcheck, withthe new test pinning the behaviour.
Related issue number
Fixes #12994
Checklist
CONTRIBUTORS.txtCHANGES/folder12994.bugfix.rstbugfixDrafted with Zo Bot; reviewed by @HrachShah.